/**
 * File name: ARFFFileBucketWriter.java Author: Willard Wang Create date: Aug
 * 23, 2013
 */
package edu.sjtu.se.prophet.io;

import java.util.List;

import edu.sjtu.se.prophet.graph.Bucket;
import edu.sjtu.se.prophet.graph.Graph;
import edu.sjtu.se.prophet.graph.Node;
import edu.sjtu.se.prophet.utils.GraphUtil;

/**
 * @author deathspeeder
 * 
 */
public class ARFFFileClusterWriter extends AbstractARFFBucketWriter {

    public ARFFFileClusterWriter() {
        outFileName = "data-cluster.arff";
        arffName = "clusters";
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.io.AbstractARFFBucketWriter#getBuckets(edu.sjtu.se
     * .prophet.graph.Graph)
     */
    @Override
    protected List<Bucket> getBuckets(Graph graph) {
        return GraphUtil.generateSubTrees(graph);
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.io.AbstractARFFBucketWriter#getComment(edu.sjtu.se
     * .prophet.graph.Bucket)
     */
    @Override
    protected String getComment(Bucket bucket) {
        StringBuilder builder = new StringBuilder();
        for (Node node : bucket.getData()) {
            builder.append(node.getId() + " ");
        }
        return builder.toString();
    }

}
